package com.dealer.management.controller;

import com.dealer.management.common.Result;
import com.dealer.management.entity.User;
import com.dealer.management.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth")
@CrossOrigin
public class AuthController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Result login(@RequestBody User user) {
        return userService.login(user.getUsername(), user.getPassword());
    }

    @GetMapping("/userinfo")
    public Result getUserInfo() {
        return userService.getCurrentUserInfo();
    }
}
